﻿using System;
using System.ComponentModel;
using System.Reflection;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdDbTransformOverrule : OdRxOverrule
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbTransformOverrule(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdDbTransformOverrule_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbTransformOverrule obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbTransformOverrule()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbTransformOverrule(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public OdDbTransformOverrule() : this(TD_DbPINVOKE.new_OdDbTransformOverrule(), MemoryManager.GetMemoryManager().GetCurrentTransaction() == null)
		{
			MemoryTransaction currentTransaction = MemoryManager.GetMemoryManager().GetCurrentTransaction();
			if (currentTransaction != null)
			{
				currentTransaction.AddObject(new OdDbTransformOverrule(this.swigCPtr.Handle, true));
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			this.SwigDirectorConnect();
		}

		public new static OdDbTransformOverrule cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbTransformOverrule_cast(OdRxObject.getCPtr(pObj));
			OdDbTransformOverrule result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbTransformOverrule)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbTransformOverrule)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbTransformOverrule)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbTransformOverrule_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(this.SwigDerivedClassHasMethod("isA", OdDbTransformOverrule.swigMethodTypes1) ? TD_DbPINVOKE.OdDbTransformOverrule_isASwigExplicitOdDbTransformOverrule(this.swigCPtr) : TD_DbPINVOKE.OdDbTransformOverrule_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(this.SwigDerivedClassHasMethod("queryX", OdDbTransformOverrule.swigMethodTypes0) ? TD_DbPINVOKE.OdDbTransformOverrule_queryXSwigExplicitOdDbTransformOverrule(this.swigCPtr, OdRxClass.getCPtr(protocolClass)) : TD_DbPINVOKE.OdDbTransformOverrule_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdDbTransformOverrule createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbTransformOverrule_createObject();
			OdDbTransformOverrule result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbTransformOverrule)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbTransformOverrule)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbTransformOverrule)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult transformBy(OdDbEntity pSubject, OdGeMatrix3d xform)
		{
			OdResult result = (OdResult)(this.SwigDerivedClassHasMethod("transformBy", OdDbTransformOverrule.swigMethodTypes3) ? TD_DbPINVOKE.OdDbTransformOverrule_transformBySwigExplicitOdDbTransformOverrule(this.swigCPtr, OdDbEntity.getCPtr(pSubject), OdGeMatrix3d.getCPtr(xform)) : TD_DbPINVOKE.OdDbTransformOverrule_transformBy(this.swigCPtr, OdDbEntity.getCPtr(pSubject), OdGeMatrix3d.getCPtr(xform)));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getTransformedCopy(OdDbEntity pSubject, OdGeMatrix3d xform, out OdDbEntity pEnt)
		{
			IntPtr zero = IntPtr.Zero;
			OdResult result;
			try
			{
				OdResult odResult = (OdResult)(this.SwigDerivedClassHasMethod("getTransformedCopy", OdDbTransformOverrule.swigMethodTypes4) ? TD_DbPINVOKE.OdDbTransformOverrule_getTransformedCopySwigExplicitOdDbTransformOverrule(this.swigCPtr, OdDbEntity.getCPtr(pSubject), OdGeMatrix3d.getCPtr(xform), out zero) : TD_DbPINVOKE.OdDbTransformOverrule_getTransformedCopy(this.swigCPtr, OdDbEntity.getCPtr(pSubject), OdGeMatrix3d.getCPtr(xform), out zero));
				if (TD_DbPINVOKE.SWIGPendingException.Pending)
				{
					throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
				}
				result = odResult;
			}
			finally
			{
				pEnt = (OdDbEntity)Teigha.Core.Helpers.odrxCreateObjectInternal(zero, true);
			}
			return result;
		}

		public virtual OdResult explode(OdDbEntity pSubject, OdRxObjectPtrArray entitySet)
		{
			OdResult result = (OdResult)(this.SwigDerivedClassHasMethod("explode", OdDbTransformOverrule.swigMethodTypes5) ? TD_DbPINVOKE.OdDbTransformOverrule_explodeSwigExplicitOdDbTransformOverrule(this.swigCPtr, OdDbEntity.getCPtr(pSubject), OdRxObjectPtrArray.getCPtr(entitySet)) : TD_DbPINVOKE.OdDbTransformOverrule_explode(this.swigCPtr, OdDbEntity.getCPtr(pSubject), OdRxObjectPtrArray.getCPtr(entitySet)));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool cloneMeForDragging(OdDbEntity pSubject)
		{
			bool result = this.SwigDerivedClassHasMethod("cloneMeForDragging", OdDbTransformOverrule.swigMethodTypes6) ? TD_DbPINVOKE.OdDbTransformOverrule_cloneMeForDraggingSwigExplicitOdDbTransformOverrule(this.swigCPtr, OdDbEntity.getCPtr(pSubject)) : TD_DbPINVOKE.OdDbTransformOverrule_cloneMeForDragging(this.swigCPtr, OdDbEntity.getCPtr(pSubject));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool hideMeForDragging(OdDbEntity pSubject)
		{
			bool result = this.SwigDerivedClassHasMethod("hideMeForDragging", OdDbTransformOverrule.swigMethodTypes7) ? TD_DbPINVOKE.OdDbTransformOverrule_hideMeForDraggingSwigExplicitOdDbTransformOverrule(this.swigCPtr, OdDbEntity.getCPtr(pSubject)) : TD_DbPINVOKE.OdDbTransformOverrule_hideMeForDragging(this.swigCPtr, OdDbEntity.getCPtr(pSubject));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private void SwigDirectorConnect()
		{
			if (this.SwigDerivedClassHasMethod("queryX", OdDbTransformOverrule.swigMethodTypes0))
			{
				this.swigDelegate0 = new OdDbTransformOverrule.SwigDelegateOdDbTransformOverrule_0(this.SwigDirectorqueryX);
			}
			if (this.SwigDerivedClassHasMethod("isA", OdDbTransformOverrule.swigMethodTypes1))
			{
				this.swigDelegate1 = new OdDbTransformOverrule.SwigDelegateOdDbTransformOverrule_1(this.SwigDirectorisA);
			}
			if (this.SwigDerivedClassHasMethod("isApplicable", OdDbTransformOverrule.swigMethodTypes2))
			{
				this.swigDelegate2 = new OdDbTransformOverrule.SwigDelegateOdDbTransformOverrule_2(this.SwigDirectorisApplicable);
			}
			if (this.SwigDerivedClassHasMethod("transformBy", OdDbTransformOverrule.swigMethodTypes3))
			{
				this.swigDelegate3 = new OdDbTransformOverrule.SwigDelegateOdDbTransformOverrule_3(this.SwigDirectortransformBy);
			}
			if (this.SwigDerivedClassHasMethod("getTransformedCopy", OdDbTransformOverrule.swigMethodTypes4))
			{
				this.swigDelegate4 = new OdDbTransformOverrule.SwigDelegateOdDbTransformOverrule_4(this.SwigDirectorgetTransformedCopy);
			}
			if (this.SwigDerivedClassHasMethod("explode", OdDbTransformOverrule.swigMethodTypes5))
			{
				this.swigDelegate5 = new OdDbTransformOverrule.SwigDelegateOdDbTransformOverrule_5(this.SwigDirectorexplode);
			}
			if (this.SwigDerivedClassHasMethod("cloneMeForDragging", OdDbTransformOverrule.swigMethodTypes6))
			{
				this.swigDelegate6 = new OdDbTransformOverrule.SwigDelegateOdDbTransformOverrule_6(this.SwigDirectorcloneMeForDragging);
			}
			if (this.SwigDerivedClassHasMethod("hideMeForDragging", OdDbTransformOverrule.swigMethodTypes7))
			{
				this.swigDelegate7 = new OdDbTransformOverrule.SwigDelegateOdDbTransformOverrule_7(this.SwigDirectorhideMeForDragging);
			}
			TD_DbPINVOKE.OdDbTransformOverrule_director_connect(this.swigCPtr, this.swigDelegate0, this.swigDelegate1, this.swigDelegate2, this.swigDelegate3, this.swigDelegate4, this.swigDelegate5, this.swigDelegate6, this.swigDelegate7);
		}

		private bool SwigDerivedClassHasMethod(string methodName, Type[] methodTypes)
		{
			MethodInfo method = base.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, methodTypes, null);
			return method.DeclaringType.IsSubclassOf(typeof(OdDbTransformOverrule));
		}

		private IntPtr SwigDirectorqueryX(IntPtr protocolClass)
		{
			return OdRxObject.getCPtr(this.queryX((OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(protocolClass, false))).Handle;
		}

		private IntPtr SwigDirectorisA()
		{
			return OdRxClass.getCPtr(this.isA()).Handle;
		}

		private bool SwigDirectorisApplicable(IntPtr pOverruledSubject)
		{
			return this.isApplicable(Teigha.Core.Helpers.odrxCreateObjectInternal(pOverruledSubject, false));
		}

		private int SwigDirectortransformBy(IntPtr pSubject, IntPtr xform)
		{
			return (int)this.transformBy((OdDbEntity)Teigha.Core.Helpers.odrxCreateObjectInternal(pSubject, false), new OdGeMatrix3d(xform, false));
		}

		private int SwigDirectorgetTransformedCopy(IntPtr pSubject, IntPtr xform, out IntPtr pEnt)
		{
			OdDbEntity obj = OdDbEntity.createObject();
			int transformedCopy;
			try
			{
				transformedCopy = (int)this.getTransformedCopy((OdDbEntity)Teigha.Core.Helpers.odrxCreateObjectInternal(pSubject, false), new OdGeMatrix3d(xform, false), out obj);
			}
			finally
			{
				pEnt = OdDbEntity.getCPtr(obj).Handle;
			}
			return transformedCopy;
		}

		private int SwigDirectorexplode(IntPtr pSubject, IntPtr entitySet)
		{
			return (int)this.explode((OdDbEntity)Teigha.Core.Helpers.odrxCreateObjectInternal(pSubject, false), new OdRxObjectPtrArray(entitySet, false));
		}

		private bool SwigDirectorcloneMeForDragging(IntPtr pSubject)
		{
			return this.cloneMeForDragging((OdDbEntity)Teigha.Core.Helpers.odrxCreateObjectInternal(pSubject, false));
		}

		private bool SwigDirectorhideMeForDragging(IntPtr pSubject)
		{
			return this.hideMeForDragging((OdDbEntity)Teigha.Core.Helpers.odrxCreateObjectInternal(pSubject, false));
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		private OdDbTransformOverrule.SwigDelegateOdDbTransformOverrule_0 swigDelegate0;

		private OdDbTransformOverrule.SwigDelegateOdDbTransformOverrule_1 swigDelegate1;

		private OdDbTransformOverrule.SwigDelegateOdDbTransformOverrule_2 swigDelegate2;

		private OdDbTransformOverrule.SwigDelegateOdDbTransformOverrule_3 swigDelegate3;

		private OdDbTransformOverrule.SwigDelegateOdDbTransformOverrule_4 swigDelegate4;

		private OdDbTransformOverrule.SwigDelegateOdDbTransformOverrule_5 swigDelegate5;

		private OdDbTransformOverrule.SwigDelegateOdDbTransformOverrule_6 swigDelegate6;

		private OdDbTransformOverrule.SwigDelegateOdDbTransformOverrule_7 swigDelegate7;

		private static Type[] swigMethodTypes0 = new Type[]
		{
			typeof(OdRxClass)
		};

		private static Type[] swigMethodTypes1 = new Type[0];

		private static Type[] swigMethodTypes2 = new Type[]
		{
			typeof(OdRxObject)
		};

		private static Type[] swigMethodTypes3 = new Type[]
		{
			typeof(OdDbEntity),
			typeof(OdGeMatrix3d)
		};

		private static Type[] swigMethodTypes4 = new Type[]
		{
			typeof(OdDbEntity),
			typeof(OdGeMatrix3d),
			typeof(OdDbEntity).MakeByRefType()
		};

		private static Type[] swigMethodTypes5 = new Type[]
		{
			typeof(OdDbEntity),
			typeof(OdRxObjectPtrArray)
		};

		private static Type[] swigMethodTypes6 = new Type[]
		{
			typeof(OdDbEntity)
		};

		private static Type[] swigMethodTypes7 = new Type[]
		{
			typeof(OdDbEntity)
		};

		public delegate IntPtr SwigDelegateOdDbTransformOverrule_0(IntPtr protocolClass);

		public delegate IntPtr SwigDelegateOdDbTransformOverrule_1();

		public delegate bool SwigDelegateOdDbTransformOverrule_2(IntPtr pOverruledSubject);

		public delegate int SwigDelegateOdDbTransformOverrule_3(IntPtr pSubject, IntPtr xform);

		public delegate int SwigDelegateOdDbTransformOverrule_4(IntPtr pSubject, IntPtr xform, out IntPtr pEnt);

		public delegate int SwigDelegateOdDbTransformOverrule_5(IntPtr pSubject, IntPtr entitySet);

		public delegate bool SwigDelegateOdDbTransformOverrule_6(IntPtr pSubject);

		public delegate bool SwigDelegateOdDbTransformOverrule_7(IntPtr pSubject);
	}
}
